#include "appcfg.h"
#include <QDebug>
#include <QSettings>
#include <QCoreApplication>
#include <QFile>

LOG4QT_DECLARE_STATIC_LOGGER(logger, AppCfg);

AppCfg& AppCfg::getInstance() {
    static AppCfg instance;
    return instance;
}

void AppCfg::loadConfig() {
    logger()->debug() << "load app config..";
    if(!QFile::exists("conf/app.conf")) {
        logger()->error() << "Configuration file conf/app.conf does not exist.";
        return;
    }
    QSettings settings("conf/app.conf", QSettings::IniFormat);
    if (!settings.isWritable()) {
        logger()->error() << "Cannot write to conf/app.conf";
    }
    m_databasePath = settings.value("database/path").toString();
}
